From 8a7d1f5685b6d969b83d47231ec275cb4fce94f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Tue, 9 Aug 2005 22:55:20 +0000 Subject: [PATCH] cleanups --- ChangeLog | 8 +++++ autogen.sh | 4 ++- babl/babl-classes.h | 12 ++++++- babl/babl-fish.c | 82 +++++++++----------------------------------- babl/babl-fish.h | 23 ++++++++++++- babl/babl-ids.h | 8 +++-- babl/babl-sampling.h | 5 +-- 7 files changed, 68 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e03bf8..309605f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-09-09 Øyvind Kolås + + * autogen.sh: make autogen also run make + * babl/babl-classes.h: added define macro usable for sampling and + fish. + * babl/babl-fish.[ch]: cleanup of stub class + * babl/babl-sampling.h: simplification of header using a define. + 2005-09-09 Øyvind Kolås * babl/babl-conversion.c: indentation cleanup. diff --git a/autogen.sh b/autogen.sh index 4db3def..c75f9da 100755 --- a/autogen.sh +++ b/autogen.sh @@ -42,7 +42,9 @@ autoheader && \ echo "- automake." && \ automake --add-missing --gnu && \ echo && \ -./configure "$@" && exit 0 +./configure "$@" && \ +echo && \ +make && exit 0 exit 1 diff --git a/babl/babl-classes.h b/babl/babl-classes.h index 7adaa88..3b9fffe 100644 --- a/babl/babl-classes.h +++ b/babl/babl-classes.h @@ -223,16 +223,26 @@ typedef int (*BablEachFunction) (Babl *entry, const char *babl_class_name (BablClassType klass); + + #define BABL_DEFINE_CLASS(TypeName, type_name) \ \ void type_name##_init (void); \ +void type_name##_destroy (void); \ void type_name##_each (BablEachFunction each_fun, \ void *user_data); \ -void type_name##_destroy (void); \ TypeName * type_name (const char *name); \ TypeName * type_name##_id (int id); \ TypeName * type_name##_new (const char *name, \ ...); + +#define BABL_DEFINE_CLASS_NO_NEW_NO_ID(TypeName, type_name) \ + \ +void type_name##_init (void); \ +void type_name##_destroy (void); \ +void type_name##_each (BablEachFunction each_fun, \ + void *user_data); + #endif diff --git a/babl/babl-fish.c b/babl/babl-fish.c index c6fca4f..b0a3a30 100644 --- a/babl/babl-fish.c +++ b/babl/babl-fish.c @@ -27,87 +27,28 @@ static int each_babl_fish_destroy (Babl *babl, void *data) { - babl_free (babl->instance.name); babl_free (babl); return 0; /* continue iterating */ } -static BablFish * -fish_new (const char *name, - int id, - Babl *source, - Babl *destination) +BablFish * +babl_fish_new (const char *name, + Babl *source, + Babl *destination) { BablFish *self = NULL; self = babl_calloc (sizeof (BablFish), 1); self->instance.type = BABL_FISH; - self->instance.id = id; - self->instance.name = babl_strdup (name); + self->instance.id = 0; + self->instance.name = "Fishy"; self->source = (union Babl*)source; self->destination = (union Babl*)destination; assert (BABL_IS_BABL (self->source)); assert (BABL_IS_BABL (self->destination)); -/* Might make sense to allow a precalculated shortcut to - * participate in later checks for optimal conversions - - babl_add_ptr_to_list ((void ***)&(source->type.from), self); - babl_add_ptr_to_list ((void ***)&(destination->type.to), self); - */ - - return (BablFish*)self; -} - -BablFish * -babl_fish_new (const char *name, - ...) -{ - va_list varg; - BablFish *self; - - int id = 0; - Babl *source = NULL; - Babl *destination = NULL; - - const char *arg = name; - - va_start (varg, name); - - while (1) - { - arg = va_arg (varg, char *); - if (!arg) - break; - - else if (!strcmp (arg, "id")) - { - id = va_arg (varg, int); - } - - else if (!strcmp (arg, "source")) - { - source = va_arg (varg, Babl*); - } - else if (!strcmp (arg, "destination")) - { - destination = va_arg (varg, Babl*); - } - else - { - babl_log ("%s(): unhandled parameter '%s' for pixel_format '%s'", - __FUNCTION__, arg, name); - exit (-1); - } - } - - va_end (varg); - - self = fish_new (name, id, - source, destination); - if ((BablFish*) db_insert ( (Babl*)self) == self) { return self; @@ -117,6 +58,17 @@ babl_fish_new (const char *name, each_babl_fish_destroy ( (Babl*)self, NULL); return NULL; } + +/* Might make sense to allow a precalculated shortcut to + * participate in later checks for optimal conversions, then we + * should also have better generated names,. model + datatype + * is a possibility , or even full single line serialization of + * components with types. + * + babl_add_ptr_to_list ((void ***)&(source->type.from), self); + babl_add_ptr_to_list ((void ***)&(destination->type.to), self); + */ + return (BablFish*)self; } BABL_CLASS_TEMPLATE(BablFish, babl_fish, "BablFish") diff --git a/babl/babl-fish.h b/babl/babl-fish.h index d3b0fe1..4ed0ada 100644 --- a/babl/babl-fish.h +++ b/babl/babl-fish.h @@ -21,6 +21,27 @@ #define BABL_FISH_H #include "babl-classes.h" -BABL_DEFINE_CLASS(BablFish, babl_fish) + +BABL_DEFINE_CLASS_NO_NEW_NO_ID(BablFish, babl_fish) + +BablFish * +babl_fish_new (Babl *source, + Babl *destination); + +/* babl_fish_process will probably be a polymorph function + * accepting source and destination buffer pointers will be + * allowed as well as BablImage objects in their place + */ +int +babl_fish_process (BablFish *babl_fish, + void *source, + void *destination, + int n); + +/* whether the BablFish needs a BablImage to do the processing, + * or void * are sufficient. + */ +int +babl_fish_needs_image (BablFish *babl_dish); #endif diff --git a/babl/babl-ids.h b/babl/babl-ids.h index 6202121..2b284e3 100644 --- a/babl/babl-ids.h +++ b/babl/babl-ids.h @@ -35,6 +35,8 @@ enum { BABL_BLUE, BABL_ALPHA, BABL_LUMINANCE, + BABL_LUMINANCE_GAMMA_2_2, + BABL_LUMINANCE_MUL_ALPHA, BABL_RED_MUL_ALPHA, BABL_GREEN_MUL_ALPHA, BABL_BLUE_MUL_ALPHA, @@ -58,16 +60,18 @@ enum { BABL_MODEL_BASE = 10000, BABL_RGB, - BABL_RGBA, - BABL_RGBA_PREMULTIPLIED, BABL_RGB_GAMMA_2_2, + BABL_RGBA, BABL_RGBA_GAMMA_2_2, + BABL_RGBA_PREMULTIPLIED, BABL_CMY, BABL_CMYK, BABL_CMYKA, BABL_YCBCR, BABL_GRAYSCALE, + BABL_GRAYSCALE_GAMMA_2_2, BABL_GRAYSCALE_ALPHA, + BABL_GRAYSCALE_ALPHA_PREMULTIPLIED, BABL_PIXEL_FORMAT_BASE = 100000, BABL_SRGB, diff --git a/babl/babl-sampling.h b/babl/babl-sampling.h index 85d06af..5304c3f 100644 --- a/babl/babl-sampling.h +++ b/babl/babl-sampling.h @@ -22,10 +22,7 @@ #include "babl-classes.h" -void babl_sampling_init (void); -void babl_sampling_each (BablEachFunction each_fun, - void *user_data); -void babl_sampling_destroy (void); +BABL_DEFINE_CLASS_NO_NEW_NO_ID(BablSampling, babl_sampling) BablSampling * babl_sampling (int horizontal, int vertical); #endif -- 2.30.2